package com.shuzijun.leetcode.editor.cn;
public class HeBingLiangGePaiXuDeLianBiaoLcof{
    public static void main(String[] args) {
         Solution solution = new HeBingLiangGePaiXuDeLianBiaoLcof().new Solution();
    }
    //leetcode submit region begin(Prohibit modification and deletion)
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) { val = x; }
 * }
 */
class Solution {
    public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
        if (l1 == null) return l2;
        if (l2 == null) return l1;
        if (l1.val < l2.val){
            ListNode subHead = mergeTwoLists(l1.next, l2);
            l1.next = subHead;
            return l1;
        }else {
            ListNode subHead = mergeTwoLists(l1, l2.next);
            l2.next = subHead;
            return l2;
        }

    }
}
//leetcode submit region end(Prohibit modification and deletion)

}